package org.nowcoder.leetcode.arrays;

/**
 * Title  : 219. Contains Duplicate II
 * Source : https://leetcode.cn/problems/contains-duplicate-ii/
 * Author : XrazYang
 * Date   : 2023-07-25
 */

public class LeetCode_219 {
    public boolean containsNearbyDuplicate(int[] nums, int k) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j - i <= k && j < nums.length; j++) {
                if (nums[i] == nums[j]) {
                    return true;
                }
            }
        }
        return false;
    }
}
